#include <bits/stdc++.h>
using namespace std;
int n,m,L,V,h[11],d[100001],v[100001],a[100001],p[100001],r[100001];
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0'){
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch<='9'&&ch>='0'){
        x=(x<<1)+(x<<3)+ch-48;
        ch=getchar();
    }
    return x*f;
}
void work(){
	memset(h,0,sizeof(h));
    int ans=0,pre=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++)
            if(d[j]<=p[i]&&p[i]<=r[j])h[j]=1;
	}
    for(int i=1;i<=n;i++)
        pre+=h[i];
    for(int i=0;i<(1<<m);i++){
        int s=0,f=1;
        memset(h,0,sizeof(h));
        for(int j=1;j<=m;j++){
            if((i&(1<<(j-1)))==0){s++;continue;}
            for(int k=1;k<=n;k++)
                if(d[k]<=p[j]&&p[j]<=r[k])h[k]=1;
        }
        int cal=0;
        for(int j=1;j<=n;j++)cal+=h[j];
        if(cal==pre)ans=max(ans,s);
    }
    cout<<pre<<" "<<ans<<"\n";
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T=read();
    while(T--){
		n=read(),m=read(),L=read(),V=read();
        int s=0,ans=0;
        for(int i=1;i<=n;i++){
			d[i]=read(),v[i]=read(),a[i]=read();
            if(a[i]<=0&&v[i]<=V)d[i]=L+1;
            if(a[i]<0&&v[i]>V){
                if((v[i]*v[i]-V*V)%(-2*a[i])==0)
                    r[i]=d[i]+(v[i]*v[i]-V*V)/(-2*a[i])-1;
                else r[i]=d[i]+(floor((1.0*v[i]*v[i]-V*V)/(-2.0*a[i])));
            }
            if(a[i]>0&&v[i]<=V){
                if((V*V-v[i]*v[i])%(2*a[i])==0)
                    d[i]=(V*V-v[i]*v[i])/(2*a[i])+1+d[i];
                else d[i]=(ceil((1.0*V*V+0.01-1.0*v[i]*v[i])/(1.0*2*a[i])))+d[i];
            }
            if(a[i]>=0)r[i]=L;
        }
        for(int i=1;i<=m;i++){
			p[i]=read();
            s=max(s,p[i]);
        }
        if(n<=10&&m<=10){
            work();
            continue;
        }
        for(int i=1;i<=n;i++){
            if(d[i]<=s)ans++;
        }
        cout<<ans<<" ";
        if(!ans)cout<<m<<"\n";
        else cout<<m-1<<"\n";
    }
    return 0;
}
